package admin

import (
	"public_security/controllers"
	"public_security/models"
	"public_security/models/about"
)

// 本所简介 API
type AboutController struct {
	controllers.BaseController
}

func (i *AboutController) Prepare() {
	i.BasePrepare()
}

// @Title update
// @Description 修改简介
// @Param	body		body 	models.About	 true		"请求参数"
// @Success 200 success
// @router /update [post]
func (i *AboutController) Update() interface{} {
	art := new(models.About)
	err := i.RequestJsonScan(&art)
	if err != nil {
		return i.ToMessageFailed(nil, "参数错误")
	}
	err = about.Update(art)
	if err != nil {
		return i.ToMessageFailed(nil, err.Error())
	}
	return i.ToMessageSuccess(nil, "发布成功")
}

// @Title query
// @Description 查询简介
// @Param	body		body 	models.About	 true		"请求参数"
// @Success 200 {object} models.About
// @router /query [post]
func (i *AboutController) Query() interface{} {
	art := new(models.About)
	err := i.RequestJsonScan(&art)
	if err != nil {
		return i.ToMessageFailed(nil, "参数错误")
	}
	results := about.Query(art)
	return i.ToMessageSuccess(results, "查询成功")
}
